package com.suge.home.module.screen;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.Navigator;
import com.suge.common.constant.LoginConstants;

public class Logout {

	@Autowired
    private HttpServletRequest request;
	
	public void execute(Context context, Navigator nav) {
		
		String userName = (String) request.getSession().getAttribute(LoginConstants.ATTRIBUTE_USER_NAME);
		
		Long userId = (Long) request.getSession().getAttribute(LoginConstants.ATTRIBUTE_USER_ID_NUM);

		if(userName!=null){
			request.getSession().removeAttribute(LoginConstants.ATTRIBUTE_USER_NAME);
		}
		if(userId!=null ){
			request.getSession().removeAttribute(LoginConstants.ATTRIBUTE_USER_ID_NUM);
		}
		nav.redirectToLocation("http://login.taobao.com/member/logout.jhtml?spm=1.1000386.0.6.CtMQCD&f=top&out=true&redirectURL=http%3A%2F%2Fwww.taobao.com%2F");
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}


	public HttpServletRequest getRequest() {
		return request;
	}

}
